<?php
//
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($this->session('isopenvoice')){
	$return['isopenvoice']=$this->session('isopenvoice')!=2?1:0;	
}else{
	$return['isopenvoice']=1;
}
if($_RQ['op']=='main'){
    $return['member']=model('core/member')->detail($_SESSION['uid'],array('credit1','credit2','credit3','credit4','credit6','mobile','avatar','nickname'));
	$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
	$return['all_money']=pdo_getsum('jy_liangoods_sendlog',array('uniacid'=>$_SESSION['uniacid']),'goodsprice');
	$data['today_money']=pdo_getsum('jy_liangoods_sendlog',array('uniacid'=>$_SESSION['uniacid'],'gettime >'=>$daytime),'goodsprice');
    $data['today_num']=pdo_count('jy_liangoods_sendlog',array('uniacid'=>$_SESSION['uniacid'],'gettime >'=>$daytime));
    $data['all_money']=pdo_getsum('jy_liangoods_sendlog',array('uniacid'=>$_SESSION['uniacid']),'goodsprice');
    $data['all_num']=pdo_count('jy_liangoods_sendlog',array('uniacid'=>$_SESSION['uniacid']));
	set_html('title','掌上中心');
	if($_SESSION['wxapp_id']){
		$tmpid=cfc('wxapp_api')->get_tpl_template_id('17468',[1,2,3,7],'orderget','新配送任务通知','jy_peisong');
		if($tmpid){
			$tmplIds[]=$tmpid;
		}
		$return['tmplIds']=$tmplIds;
	}
	$return['data']=$data;
	exi($return);
}
if($_RQ['op']=='getnew'){
	$params=array(
		'status'=>2,
		'uniacid'=>$_SESSION['uniacid'],
	);
	$this->session('isopenvoice',1);
	$order=pdo_get('jy_liangoods_sendlog',$params);
	if($order['id']){
	    $last_noticetime= $this->session('last_noticetime');
	    if(!$last_noticetime || $last_noticetime<time()-60){
            $this->model('notice')->notice_newget($order['id'],$_SESSION['uid']);
            $this->session('last_noticetime',time());
        }
		exi($order);
	}else{
		exi('none');
	}
}
if($_RQ['op']=='setopenvoice'){
	$isopenvoice=$_RQ['isopenvoice'];
	$isopenvoice=$isopenvoice?1:2;
	$this->session('isopenvoice',$isopenvoice);
	exi($return);
}
?>